package query

import (
	"ssadmin/common/query"
	"strings"
)

type UserAppQuery struct {
	query.Pagination `search:"-"`
	Status           string `form:"status"`
	Search           string `form:"search"`

	AgentId string
}

type UserAppGetReq struct {
	AppId string `form:"appId"`
}

type UserAppDeleteReq struct {
	AppId         string `json:"appId"`
	AppIds        string `json:"appIds"`
	CurrentUserId string
}

func (s *UserAppDeleteReq) GetAppId() []string {
	if len(s.AppIds) > 0 {
		return validList(strings.Split(s.AppIds, ","))
	} else {
		return validList(strings.Split(s.AppId, ","))
	}
}

func validList(array []string) []string {
	validArr := make([]string, 0)
	for _, val := range array {
		if val != "" {
			validArr = append(validArr, val)
		}
	}
	return validArr
}

//数据库参数
type UserAppDbParam struct {
	AppId string `search:"type:exact;column:app_id;table:sys_user_app"`
}
